#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QProcess>

#include <QTime>
#include <QTimer>
#include <QDateTime>

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include "QDebug"


#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>
#include <iostream>
#include <QDebug>

#include <QTextCodec>

#include <unistd.h>
#include <QThread>  // 用于 QThread::msleep()

#include <QNetworkConfigurationManager>
#include <chart.h>

#include "iot_mqtt/data_model_basic_demo.h"
#include "iot_mqtt/mqtt_sdk/aiot_mqtt_api.h"

//#define USB_4G    "/dev/ttyS1"
//#define USB_Lora  "/dev/ttyS2"

#define USB_4G    "/dev/ttyACM0"
#define USB_Lora  "/dev/ttyUSB0"

//#define usb_4G "/dev/ttyS1"
//#define usb_lora "/dev/ttyS2"
namespace Ui {
class Widget;
}
class chart;
class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = nullptr);
    ~Widget();

       chart *mychart_record=NULL;
private slots:
     void timer_task1_showcan();
     void Lora_Read_all();
     void Init_Lora();
     void Init_4G();
     void my_InsertSQL(int8_t zd_name);
     void Send_4G_message(const QByteArray &message);
     void timer_networkonoff_task();
     void comeBackToPrev();
     void back_color_set();

     bool isNetWorkOnline()
     {
         QNetworkConfigurationManager mgr;
         return mgr.isOnline();
     }


     void on_open_jie_button_clicked();

     void on_close_jie_button_clicked();


     void on_open_all_button_clicked();

     void on_Goto_page_button_clicked();

private:
    Ui::Widget *ui;
    QTimer     *timer;
    QTimer     *timer_canshu;
    QSerialPort mlora_serial;
    QSerialPort m4G_serial;
};

#endif // WIDGET_H
